<template>

  <view class="other-card">
    <view class="c-top">
      <view class="c-update" @click="toDetails">· {{info.time}} {{tipsText}}</view>
      <icon-card v-if="info.user?.status != 1" :ids="iconIds"></icon-card>
    </view>
    <view class="p-title" @click="toDetails">
      <view :class="genderClass">{{info.user?.gender}}·{{info.user?.year}}年</view>
      <image :src="vipImg" mode="scaleToFill" class="p-vip"></image>
    </view>

    <view class="o-con">
      <view class="o-desc" @click="toDetails">
        <text v-if="info.user?.at_province">{{info.user.at_province}} {{info.user.at_city}}</text>
        <text v-if="info.user?.height">{{info.user.height}}cm</text>
        <text v-if="info.user?.edu">{{info.user.edu}}</text>
        <text v-if="info.user?.income">{{info.user.income}}</text>
        <text v-if="info.user?.occupation">{{info.user.occupation}}</text>
      </view>

      <view class="p-img-item" @click="previewImg" v-if="imgList && imgList.length">
        <image style="width:100%; height:100%; z-index:-1" :src="imgList[0]" mode="scaleToFill"></image>
        <view class="img-mask" v-if="!info.user.look"></view>
        <view class="img-num">共{{ imgList.length}}张</view>
      </view>
    </view>

    <!-- 按钮 -->
    <btns-card :info="info.user" :btn-items="[2,3]"></btns-card>

    <view class="other-mask" v-if="info.user?.status == 1">
      <view class="other-tips">对方暂时隐藏了相亲卡</view>
    </view>

  </view>
</template>
 
<script setup>
// 引入组件
import BtnsCard from "@/components/person/btns-card.vue";
import IconCard from "@/components/person/icon-card.vue";
import vipIcon1 from "@/static/common/vip-jd.svg";
import vipIcon2 from "@/static/common/vip-nd.svg";
import vipIcon3 from "@/static/common/vip-yj.svg";
import vipIcon4 from "@/static/common/vip-zz.svg";
import { setItem } from "@/utils/storage";
import useStore from "@/store";
const { person } = useStore();
const props = defineProps({
  info: {
    type: Object,
    default: () => {},
  },
  pageType: {
    type: String,
    default: "",
  },
});

const vipConfs = shallowReactive({
  季度会员: vipIcon1,
  年度会员: vipIcon2,
  永久会员: vipIcon3,
  至尊会员: vipIcon4,
});

const tipsConfs = shallowReactive({
  look_my: "访问了您",
  collect_my: "收藏了我",
  contact_my: "查看了我的电话",
  my_contact: "我联系过",
});

const tipsText = computed(() => tipsConfs[props.pageType]);
const vipImg = computed(() => {
  const { title } = props.info?.member || {};
  return vipConfs[title];
});
const iconIds = computed(() => {
  const { user } = props.info;
  return { user_id: user?.id };
});

const genderClass = computed(() => {
  const cObj = {
    男: "boy-text",
    女: "girl-text",
  };
  return cObj[props.info.user?.gender];
});

const imgList = computed(() => {
  const { imgs } = props.info.user;
  return imgs.map((v) => v.img_url);
});
// 查看照片
const previewImg = (item) => {
  setItem("imgs", imgList.value);
  const { look, id } = props.info.user;
  person.updatePersonId({ user_id: id, look });
  uni.navigateTo({
    url: "/subPages/preview/index?cur=0&look=" + look + "&id=" + id,
  });
};

const toDetails = () => {
  const { look, id, status } = props.info.user;
  if (status && status == 1) return;
  person.updatePersonId({ user_id: id, look });
  uni.navigateTo({ url: "/subPages/details/index" });
};
</script>
 
<style lang='scss' scoped>
.other-card {
  background: #fff;
  border-radius: 30rpx;
  margin: 20rpx;
  padding: 40rpx 30rpx;
  position: relative;
  overflow: hidden;
  .boy-text {
    color: #4a61ff;
  }
  .girl-text {
    color: #ff5c55;
  }
  .c-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 30rpx;
    .c-update {
      padding: 5rpx 20rpx;
      font-weight: 500;
      font-size: 24rpx;
      color: #fe7b11;
      background: rgba(254, 123, 17, 0.1);
      border-radius: 40rpx;
    }
  }
  .p-title {
    display: flex;
    align-items: center;
    font-size: 52rpx;
    font-weight: bold;
  }
  .p-vip {
    width: 150rpx;
    height: 48rpx;
    margin-left: 20rpx;
  }
  .o-con {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20rpx 0;
    border-bottom: 1rpx solid #e5e5e5;
    margin-bottom: 10rpx;
    .o-desc {
      font-weight: 800;
      font-size: 36rpx;
      color: #333;
      display: flex;
      flex-wrap: wrap;
      flex: 1;
      margin-left: -10rpx;
      overflow: hidden;

      text {
        padding: 0 20rpx;
        margin-bottom: 20rpx;
        margin-left: -10rpx;
        padding-right: 30rpx;
      }
      text + text {
        border-left: 1rpx dashed #aaa;
      }
    }
    .p-img-item {
      width: 160rpx;
      height: 160rpx;
      border-radius: 10rpx;
      position: relative;
      overflow: hidden;
      margin-top: -50rpx;
      .img-num {
        width: 160rpx;
        height: 40rpx;
        line-height: 40rpx;
        text-align: center;
        background: rgba(0, 0, 0, 0.6);
        font-weight: 500;
        font-size: 24rpx;
        color: #fff;
        position: absolute;
        left: 0;
        bottom: 0;
      }
    }
  }
}

.other-mask {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 30rpx;
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 80%;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(10px);
  .other-tips {
    font-weight: 800;
    font-size: 40rpx;
    color: #ff5c55;
  }

  .other-btn {
    width: 240rpx;
    height: 80rpx;
    line-height: 80rpx;
    background: #fff;
    border: 1rpx solid #ff5c55;
    margin-top: 20rpx;
    color: #ff5c55;
    border-radius: 80rpx;
  }
}
</style>